package com.suket.jnn;

import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

public class NetworkSupport {

  static Logger logger = Logger.getLogger(NetworkSupport.class);

  public static void info( Network network ) {
    if ( network == null ) {
      logger.log(Level.WARN, "Failed to perform info , found null network");
      return;
    }
  }

  public static String infoWeights( Network network ) {
    String result = "";
    if ( network == null ) {
      logger.log(Level.WARN, "Failed to perform info weights "
          + ", found null network");
      return result;
    }
    List listHiddenLayers = network.getHiddenLayers();

    Iterator iterHiddenLayers = listHiddenLayers.iterator();
    while ( iterHiddenLayers.hasNext() ) {
      Layer hiddenLayer = (Layer) iterHiddenLayers.next();
      result += CommonUtil.tab(2) + hiddenLayer.getName() + ": \n";
      String infoLayerWeights = LayerSupport.infoWeights(hiddenLayer, 4);
      result += infoLayerWeights;
    }

    Layer outputLayer = network.getOutputLayer();
    result += CommonUtil.tab(2) + outputLayer.getName() + ": \n";
    String infoLayerWeights = LayerSupport.infoWeights(outputLayer, 4);
    result += infoLayerWeights;

    return result;
  }

}
